/*
 * Copyright (c) 2012 Universidad Antonio de Nebrija.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Apache License v2.0
 * which accompanies this distribution, and is available at
 * http://www.apache.org/licenses/LICENSE-2.0.html
 * 
 * Contributors:
 *    Universidad Antonio de Nebrija - initial API, implementation and documentation
 */
package com.nebrija.riif.parser;

import org.antlr.runtime.tree.Tree;

import com.nebrija.riif.model.Component;
import com.nebrija.riif.model.FailMode;
import com.nebrija.riif.model.RIIFElement;

/**
 * Processor to convert a fail_mode token from the tree into a FailMode object
 * @author asanchep
 *
 */
public class FailModeElementProcessor implements RIIFParserProcessor{


		@Override
		public RIIFElement apply(RIIFElement container, Tree t) {
			if(! (container instanceof Component)){
				return null;
			}
			// Read the id, create the FailMode object and add it to the component
			String id = t.getChild(0).getText();
			FailMode fm = new FailMode(id);
			((Component)container).addFailMode(fm);
			return fm;
		}
		

}
